/*
  ==============================================================================

    RMS.cpp
    Created: 15 Feb 2015 12:12:38pm
    Author:  Alistair Barker

  ==============================================================================
*/

#include "RMS.h"

RMS::RMS()
{
    buffer.setSize(1, 500);
    writePtr = 0;
}

double RMS::calculateRMS(double input)
{
    buffer.setSample(0, writePtr, input);
    
    writePtr++;
    
    if (writePtr >= buffer.getNumSamples()) writePtr = 0;
    
    return buffer.getRMSLevel(0, 0, buffer.getNumSamples() - 1);
}